var app = getApp();

Page({
    data: {
        navH: 0,
        showDrawShade: !0,
        id: 0,
        user: [],
        isReceive: !0,
        rp_uid: 0,
        skip_id: 1,
        hot_page: 1,
        hot_loading: !1,
        hotGoodsList: !1,
        hotLeft: 0,
        confirmBtnDisabled: !1,
        imgPath: app.getImgUrl(),
        videoAd: !1,
        video_ad_code: !1,
        is_look_video: !0
    },
    getReceiveRpw: function() {
        var t = this;
        app.globalData.userInfo ? app.util.request({
            url: "entry/wxapp/getReceiveRpw",
            data: {
                id: t.data.id,
                rp_uid: t.data.rp_uid
            },
            success: function(a) {
                console.log(a.data.data), t.setData({
                    user: a.data.data
                }), 1 == t.data.user[0].status && t.setData({
                    showDrawShade: !1,
                    isReceive: !1
                });
            }
        }) : app.checkLogin();
    },
    getHotGoods: function() {
        var t = this;
        t.data.hot_loading || (t.data.hot_loading = !0, app.util.request({
            url: "entry/wxapp/getHotGoods",
            showLoading: !1,
            data: {
                page: t.data.hot_page,
                channel_type: 1
            },
            success: function(a) {
                a.data.data.length < 1 || (t.data.hotGoodsList = 1 == t.data.hot_page ? a.data.data : t.data.hotGoodsList.concat(a.data.data), 
                t.setData({
                    hotGoodsList: t.data.hotGoodsList
                }), console.log(t.data.hotGoodsList), t.data.hot_page++);
            },
            complete: function() {
                t.data.hot_loading = !1;
            }
        }));
    },
    toGoodsPage: function(a) {
        console.log(a);
        var t = a.currentTarget.dataset.goods_id;
        void 0 === a.currentTarget.dataset.source ? (a = "&source=" + this.data.skip_id, 
        wx.navigateTo({
            url: "../goods/goods?goods_id=" + t + a
        })) : wx.navigateTo({
            url: "../goods/goods?goods_id=" + t
        });
    },
    onLoad: function(a) {
        this.setData({
            navH: app.globalData.navHeight,
            id: a.id,
            rp_uid: a.rp_uid
        }), this.getHotGoods(), this.getReceiveRpw();
    },
    loginAfter: function(a) {
        app.loginAfter(a);
    },
    loginCancel: function() {
        app.loginCancel();
    },
    navBack: function() {
        wx.navigateBack();
    },
    chooseDrawShade: function(a) {
        var t, o, e, n;
        app.globalData.userInfo ? (o = (t = this).data.user[0].id, e = t.data.user[0].money, 
        n = t.data.user[0].nickname, t.setData({
            confirmBtnDisabled: !0
        }), wx.showLoading({
            title: "加载中"
        }), app.util.request({
            url: "entry/wxapp/drawRedPacket",
            data: {
                id: o,
                money: e,
                nickname: n
            },
            success: function(a) {
                console.log(a.data.data), wx.hideLoading(), t.setData({
                    confirmBtnDisabled: !1,
                    showDrawShade: !1
                });
            }
        })) : app.checkLogin();
    },
    toRedEnvelope: function() {
        wx.navigateTo({
            url: "./red-envelope"
        });
    },
    toIndex: function() {
        wx.switchTab({
            url: "../index/index"
        });
    },
    onReady: function() {},
    onShow: function() {
        app.reUserInfo();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.hot_page = 1, this.data.hot_loading = !1, this.getHotGoods(function() {
            wx.stopPullDownRefresh();
        });
    },
    onReachBottom: function() {}
});